package com.navinfo.platform.bigdata.dto;

import com.navinfo.platform.bigdata.util.EntityConvert;
import com.navinfo.stream.qingqi.protocol.java.LCPredictiveMaintenance;

public class MaintenanceEvent3Dto {
    private double mileage;
    private double speed;
    private int clutchSwitch;
    private int neutralSwitch;
    private long engineTorque;
    private long flywheelTorque;
    private double rotation;
    private double maxRotation2;
    private int gearPosition2;
    private double synchronisedTime2;
    private long startingEnergy2;
    private double maxRotation3;
    private int gearPosition3;
    private double synchronisedTime3;
    private long shiftEnergy3;

    public double getMileage() {
        return mileage;
    }

    public void setMileage(double mileage) {
        this.mileage = mileage;
    }

    public double getSpeed() {
        return speed;
    }

    public void setSpeed(double speed) {
        this.speed = speed;
    }

    public int getClutchSwitch() {
        return clutchSwitch;
    }

    public void setClutchSwitch(int clutchSwitch) {
        this.clutchSwitch = clutchSwitch;
    }

    public int getNeutralSwitch() {
        return neutralSwitch;
    }

    public void setNeutralSwitch(int neutralSwitch) {
        this.neutralSwitch = neutralSwitch;
    }

    public long getEngineTorque() {
        return engineTorque;
    }

    public void setEngineTorque(long engineTorque) {
        this.engineTorque = engineTorque;
    }

    public long getFlywheelTorque() {
        return flywheelTorque;
    }

    public void setFlywheelTorque(long flywheelTorque) {
        this.flywheelTorque = flywheelTorque;
    }

    public double getRotation() {
        return rotation;
    }

    public void setRotation(double rotation) {
        this.rotation = rotation;
    }

    public double getMaxRotation2() {
        return maxRotation2;
    }

    public void setMaxRotation2(double maxRotation2) {
        this.maxRotation2 = maxRotation2;
    }

    public int getGearPosition2() {
        return gearPosition2;
    }

    public void setGearPosition2(int gearPosition2) {
        this.gearPosition2 = gearPosition2;
    }

    public double getSynchronisedTime2() {
        return synchronisedTime2;
    }

    public void setSynchronisedTime2(double synchronisedTime2) {
        this.synchronisedTime2 = synchronisedTime2;
    }

    public long getStartingEnergy2() {
        return startingEnergy2;
    }

    public void setStartingEnergy2(long startingEnergy2) {
        this.startingEnergy2 = startingEnergy2;
    }

    public double getMaxRotation3() {
        return maxRotation3;
    }

    public void setMaxRotation3(double maxRotation3) {
        this.maxRotation3 = maxRotation3;
    }

    public int getGearPosition3() {
        return gearPosition3;
    }

    public void setGearPosition3(int gearPosition3) {
        this.gearPosition3 = gearPosition3;
    }

    public double getSynchronisedTime3() {
        return synchronisedTime3;
    }

    public void setSynchronisedTime3(double synchronisedTime3) {
        this.synchronisedTime3 = synchronisedTime3;
    }

    public long getShiftEnergy3() {
        return shiftEnergy3;
    }

    public void setShiftEnergy3(long shiftEnergy3) {
        this.shiftEnergy3 = shiftEnergy3;
    }

    public static MaintenanceEvent3Dto parseProto(LCPredictiveMaintenance.MaintenanceEvent3 maintenanceEvent3){
        MaintenanceEvent3Dto maintenanceEvent3Dto = new MaintenanceEvent3Dto();
        maintenanceEvent3Dto.setMileage(maintenanceEvent3.getMileage());
        maintenanceEvent3Dto.setSpeed(maintenanceEvent3.getSpeed());
        maintenanceEvent3Dto.setClutchSwitch(maintenanceEvent3.getClutchSwitch());
        maintenanceEvent3Dto.setNeutralSwitch(maintenanceEvent3.getNeutralSwitch());
        maintenanceEvent3Dto.setEngineTorque(maintenanceEvent3.getEngineTorque());
        maintenanceEvent3Dto.setFlywheelTorque(maintenanceEvent3.getFlywheelTorque());
        maintenanceEvent3Dto.setRotation(maintenanceEvent3.getRotation());
        maintenanceEvent3Dto.setMaxRotation2(maintenanceEvent3.getMaxRotation2());
        maintenanceEvent3Dto.setGearPosition2(maintenanceEvent3.getGearPosition2());
        maintenanceEvent3Dto.setSynchronisedTime2(maintenanceEvent3.getSynchronisedTime2());
        maintenanceEvent3Dto.setStartingEnergy2(maintenanceEvent3.getStartingEnergy2());
        maintenanceEvent3Dto.setMaxRotation3(maintenanceEvent3.getMaxRotation3());
        maintenanceEvent3Dto.setGearPosition3(maintenanceEvent3.getGearPosition3());
        maintenanceEvent3Dto.setSynchronisedTime3(maintenanceEvent3.getSynchronisedTime3());
        maintenanceEvent3Dto.setShiftEnergy3(maintenanceEvent3.getShiftEnergy3());
        return maintenanceEvent3Dto;
    }

    /**
     * 解析成String拼接字符串
     * @param maintenanceEvent3
     * @return
     */
    public static String parseString(LCPredictiveMaintenance.MaintenanceEvent3 maintenanceEvent3){
        return EntityConvert.convert(
                maintenanceEvent3.getMileage(),
                maintenanceEvent3.getSpeed(),
                maintenanceEvent3.getClutchSwitch(),
                maintenanceEvent3.getNeutralSwitch(),
                maintenanceEvent3.getEngineTorque(),
                maintenanceEvent3.getFlywheelTorque(),
                maintenanceEvent3.getRotation(),
                maintenanceEvent3.getMaxRotation2(),
                maintenanceEvent3.getGearPosition2(),
                maintenanceEvent3.getSynchronisedTime2(),
                maintenanceEvent3.getStartingEnergy2(),
                maintenanceEvent3.getMaxRotation3(),
                maintenanceEvent3.getGearPosition3(),
                maintenanceEvent3.getSynchronisedTime3(),
                maintenanceEvent3.getShiftEnergy3()
        );
    }

    /**
     * 反解析成PB对象
     * @param str
     * @return
     */
    public static LCPredictiveMaintenance.MaintenanceEvent3 parsePB(String str){
        LCPredictiveMaintenance.MaintenanceEvent3.Builder builder = null;
        try{
            String[] revert = EntityConvert.revert(str);
            if(null!=revert && revert.length>=5){
                builder = LCPredictiveMaintenance.MaintenanceEvent3.newBuilder();

                builder.setMileage(Double.valueOf(revert[0]));
                builder.setSpeed(Double.valueOf(revert[1]));
                builder.setClutchSwitch(Integer.valueOf(revert[2]));
                builder.setNeutralSwitch(Integer.valueOf(revert[3]));
                builder.setEngineTorque(Long.valueOf(revert[4]));
                builder.setFlywheelTorque(Long.valueOf(revert[5]));
                builder.setRotation(Double.valueOf(revert[6]));
                builder.setMaxRotation2(Double.valueOf(revert[7]));
                builder.setGearPosition2(Integer.valueOf(revert[8]));
                builder.setSynchronisedTime2(Double.valueOf(revert[9]));
                builder.setStartingEnergy2(Long.valueOf(revert[10]));
                builder.setMaxRotation3(Double.valueOf(revert[11]));
                builder.setGearPosition3(Integer.valueOf(revert[12]));
                builder.setSynchronisedTime3(Double.valueOf(revert[13]));
                builder.setShiftEnergy3(Long.valueOf(revert[14]));

            }
        }catch (Exception e){
            e.printStackTrace();
        }

        return builder==null? null : builder.build();
    }
}
